//
//  UIBarButtonItem-Extension.swift
//  weiboswift
//
//  Created by dingzhibing on 2017/3/7.
//  Copyright © 2017年 dingzhibing. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    convenience init(title:String, fontSize:CGFloat = 16, target:AnyObject?, action:Selector,isBack:Bool = false) {
        let btn:UIButton = UIButton.textButton(title: title, fontSize: fontSize, normalColor:UIColor.darkGray , highlightedColor: UIColor.orange,backgroundImageName: nil)
        btn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        
        if isBack{
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named:imageName), for: UIControlState.normal)
            btn.setImage(UIImage(named:imageName+"_highlighted"), for: UIControlState.highlighted)
            btn.sizeToFit()
        }
        
        //实例化 uibarbuttonitem
        self.init(customView:btn)
    }
}
